package com.example.fairplay.newfpregistration.fragments;

import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;

import com.example.fairplay.newfpregistration.R;
import com.example.fairplay.newfpregistration.adapter.StudentPicAdapter;
import com.example.fairplay.newfpregistration.ui.MatchPickActivity;
import com.example.mylibrary.activity.BaseFragment;
import com.example.mylibrary.adapter.RvListener;
import com.example.mylibrary.data.ByteImg;
import com.example.mylibrary.data.DBManager;
import com.example.mylibrary.data.StudentInfo;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by fairplay on 2018/6/4.
 */

public class CheckFragment extends BaseFragment {
    @Bind(R.id.tv_check_time)
    TextView tvCheckTime;
    @Bind(R.id.tv_check_project)
    TextView tvCheckProject;
    @Bind(R.id.tv_check_state)
    TextView tvCheckState;
    @Bind(R.id.rv_check_info)
    RecyclerView rvCheckInfo;
    @Bind(R.id.btn_update_info)
    Button btnUpdateInfo;
    private View mView;
    private StudentPicAdapter mAdapter;
    private List<ByteImg> mList=new ArrayList<>();

    private List<StudentInfo> mSudents=new ArrayList<>();



    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        mView = inflater.inflate(R.layout.fragment_check, container, false);
        ButterKnife.bind(this, mView);
        initObjects();
        initViews();
        initData();
        setListeners();

        return mView;
    }

    @Override
    protected void findViews() {

    }

    @Override
    protected void initObjects() {

    }

    @Override
    protected void initViews() {
        mAdapter=new StudentPicAdapter(mActivity, mList,null);
        rvCheckInfo.setAdapter(mAdapter);
    }

    @Override
    protected void initData() {
        mSudents=DBManager.getInstance(mActivity).queryStuInfos2(MatchPickActivity.sortId);
        for (int i = 0; i <mSudents.size() ; i++) {
            ByteImg byteImg=DBManager.getInstance(mActivity).queryStuImg(mSudents.get(i).getStudenCode());
            if(byteImg!=null){
                mList.add(byteImg);
            }
        }
        mAdapter.notifyDataSetChanged();
    }

    @Override
    protected void setListeners() {

    }



    @Override
    public void onDestroyView() {
        super.onDestroyView();
        ButterKnife.unbind(this);
    }
}
